u`
Ep.64uXR[vvĊJ܂

p.64 XR[v

EuvuΏ۔͈́v̂ƂŁAC#Ȃǂł͕ϐȂǂ̗L͈
EMain\bhȂǂ{`}ubNƂ
EubN̒Ő錾ꂽϐ̓ubN݂̂ŗL
EubN̒ɃubNiq\ĵŁAÕubN̒Ő錾ꂽϐ͓̃ubNłL
EȂAC/C++ł̓XR[vقȂ΁AO̕ϐ`ł邪AC#ł͋֎~B
EubN̓vO}̓słł邪AړImł͂ȂubN͓ǂ݂₷𑹂Ȃ̂ŐȂ
E  p.64 scope01.cs

p.65 ^ϊ

Ep.45Parsê悤ɁAːl̕ϊs\bh
Eɑ΂āAl^ǂ̕ϊsƂLXgƂ
EF (^)l
EF int a = (int)4.14; double d = (double)3, ave = (a + 3) / (double)2;
El𐮐^ɃLXgƁA_ȉ͐؂̂ĂɂȂ
E͈͂̋^̕ϐɁA͈͂̍L^̕ϐɂ̓LXg
EF long g = 5; int a = (int)g;

p.66y⑫z

E5sڂ́ub = (byte)2;v́ub = (byte)a;v̌
EvOcast01.cs͎sĂ\Ȃ

AWKFp.66 cast01.cs

Eab̒l\鏈ǉ悤

쐬

//AWKFp.66 cast01.cs
using System;
class cast01
{
    public static void Main()
    {
        long a = 2;
        byte b;
        b = (byte)a;
        Console.WriteLine("a = {0}, b = {0}", a, b); //yǉz
    }
}

p.66 񋓌^

EA̐ɖOt
EɂO[vAOĎʂꍇɗp
E`F enum 񋓖 { 񋓎q, c }
@F enum janken { goo, choki, paa };
E񋓎q̕\̋Kl0,1,2,cAw肷邱Ƃł
E`F enum 񋓖 { 񋓎q = l, c }
@F enum janken { goo = 7, choki = 8, paa = 9 };
EȂA񋓎q͎I+1̂ŁAԊu1Ȃȗł
@F enum janken { goo = 7, choki, paa };
E񋓂p邱ƂŁA}WbNio[(̂Ȃle)΍ɂȂB
@const̏ʃo[Wł
EȂA񋓌^^Ȃ̂ŁA񋓎q\ɗpꍇAint^ȂǂɃLXg邱
@F enum janken { goo, choki, paa }; int myhand = (int)janken.goo;

p.68 enum01.cs

//p.68 enum01.cs
using System;
class enum01
{
    enum MyMonth //񋓂̒`iMain\bh̊Oōsj
    {
        Jan = 1, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec 
    };
    public static void Main()
    {
        Console.WriteLine("Apr{0}", (int)MyMonth.Apr); //yǉz
        Console.WriteLine("May{0}", (int)MyMonth.May); //yǉz
    }
}

 p.69 3.14͊܂͌tH[Ƃ܂

p.73 ^

El^ɑ^͑傫ŒȂ̂ŁAϐi[f[^w
E΂āA0ȏ̕̕тȂ̂ŁA傫܂Ȃ
ËׁA^͎Qƌ^Ɋ܂܂
EQƌ^̓NXƂĒ`ȀꍇAstringNXS
Ëׁustringv͕^̌^ƂĂp\
ENXɂ̓f[^ƋɃf[^p鏈LqłBꂪ\bhAvpeBȂ
EStringNX̃\bhAvpeBȂǂ́ustring^ϐ.\bhvustring^ϐ.vpeBvŌĂяo
EStringNXɂLengthvpeB`ĂApƕ
ESring^ϐ[]ƂƁA̒1oB擪0Ƃԍɗ^Ɨǂ
@ ͌qz̎d|
EStringNXɂCopy\bhApƕRs[ł
E܂Aw肵(擪0)ɂ邩ԂIndexOf('')\bhAw肵񂪉ڂn܂邩ԂƂłIndexOf("")\bh
@ ͌qI[o[[h̎d|

p.73 string01.cs

//p.73 string01.cs
using System;
class string01
{
    public static void Main()
    {
        string str = "͂悢VCł";
        string mystr;
        char c;
        // LengthvpeBŕ̒𒲂ׂ
        Console.WriteLine("str͒{0}ł", str.Length);
        //^ϐcɕstr5Ԗڂ̕
        c = str[4];
        Console.WriteLine("5Ԗڂ́̕u{0}vł", c);
        //strmystrɃRs[
        mystr = String.Copy(str);
        Console.WriteLine("mystr = {0}", mystr);
        //̌
        int n = str.IndexOf('');
        Console.WriteLine("''oĂ̂{0}Ԗڂ̕", n + 1);
        n = str.IndexOf("悢");
        Console.WriteLine("Ɂu悢voĂ̂{0}ڂ", n + 1);
    }
}

p.78 KP qg

E1NԂ̕b͓~24ԁ~60~60b

쐬

//p.78 KP
using System;
class ex0301
{
    public static void Main()
    {
        Console.WriteLine("1N{0:#,#}bł", 365 * 24 * 60 * 60);
    }
}

p.78 KQ qg

EMath.PIC#񋟂Ă萔ŁA~i[Ă
E~̖ʐς́u~~a~av
Ea͎(double^)œ͂Ɨǂ

쐬

//p.78 KQ
using System;
class ex0302
{
    public static void Main()
    {
        Console.Write("aF");
        double r = double.Parse(Console.ReadLine());
        Console.WriteLine("ʐς{0}ł", Math.PI * r * r);
    }
}

S Zq

p.79 ƉZq

Eu+vu-vȂǂ̌vZ⑀\LPZqƂ
EZq̑ΏۂIyhijƂAZq̎ނɂėp鐔قȂ
@Fua + bv̓Iyh2Ȃ̂ŁuQ+ZqvƂ
EvZČʂ𓾂邱Ƃu]vƂ
@FQ+Zq̕]͉ZʂɂȂ
Éu=vZqłÁuQ=ZqvɂȂĂ
EQ=Zq̕]͑lɂȂ
@F c = 3 + 4 ƂƁu3 + 4v̕]ł7cɑA]7
EZq͊{Iɍ]邪AuQ=Zqv̂悤ɉE]̂

p.80 expression01 

// p.80 expression01 
using System;
class expression01 {
    public static void Main() {
        int a = 0;
        Console.WriteLine("a = {0}", a);
        //w肷Ƃ̕](l)\ł(ł͑l)
        Console.WriteLine("(a = 7)̒l{0}", a = 7); //7ƂȂ
    }
}

p.81 ZpZq

EQ+ZqFQɐl^łΉZʂԂBǂ炩łȂΘAʂԂ
EQ-ZqFQɐl^ł΍ӂEӂʂԂB
EQ*ZqFQɐl^ł΍ӂƉEӂ̐ςԂB
EQ/ZqFQɐ^ł΍ӂEӂŊ̐Ԃ(_ȉ؂̂)Bǂ炩ł^ȂΏԂB
@ Eӂ̒l0ƎsG[AEӂu0vƕ@G[ɂȂ
@ Eӂ0.0ƁA-0.0-ɂȂB

p.81 add01.cs

//p.81 add01.cs
using System;
class add01
{
    public static void Main()
    {
        Console.WriteLine(3 + 6); //Z9
        Console.WriteLine(3.0 + 6); //Z9.0\́u9v
        Console.WriteLine("3.5" + 6); //A"3.56"\́u3.56v
        Console.WriteLine(3.5 + "6"); //A"3.56"\́u3.56v
        Console.WriteLine(); //ŝ
        Console.WriteLine("(3.0 + 6)̌^{0}", 
            (3.0 + 6).GetType()); //double + int Ȃ̂ŉZ System.Double
        Console.WriteLine("3.5 + int6̌^{0}",
            ("3.5" + 6).GetType()); //string + int Ȃ̂ŘA System.String
        Console.WriteLine("double3.5 + 6̌^{0}",
            (3.5 + "6").GetType()); //double + string Ȃ̂ŘA System.String
    }
}

p.83 division01.cs

//p.83 division01.cs
using System;
class division01
{
    public static void Main()
    {
        Console.WriteLine("10 / 3 = {0}", 10 / 3); // intintȂ̂intŏ_ȉ؂̂
        Console.WriteLine("(10 / 3)̌^{0}",
            (10 / 3).GetType()); // intȂ̂System.Int32
        Console.WriteLine("10 / 3.0 = {0}", 10 / 3.0); // intdoubleȂ̂double
        Console.WriteLine("(10 / 3.0)̌^{0}",
            (10 / 3.0).GetType()); // doubleȂ̂System.Double
    }
}

p.84 ]Zq

EQ%ZqFQɐl^ł΍ӂEӂŊ]Ԃ
@F 1 % 0.3  0.1
EȂA̐̏ꍇAC#̃[ɂČvẐŒ
@ o𐳂̐ɂď]𓾂ĂAӂ̕tĂ
  Console.WriteLine(" 10 % -3 = {0}",  10 % -3); // 10-3-3] 1ƂȂ
  Console.WriteLine("-10 %  3 = {0}", -10 %  3); //-10 3-3]-1ƂȂ
  Console.WriteLine("-10 % -3 = {0}", -10 % -3); //-10-3 3]-1ƂȂ
E⑫F̐̏]Z𐄏Ȃꍇ

//p.84 mod01.cs
using System;
class mod01
{
    public static void Main()
    {
        Console.WriteLine("10 % 3 = {0}", 10 % 3); //int % int Ȃ̂Ōʂint
        Console.WriteLine("13.53 % 2 = {0}", 13.53 % 2); //double % int Ȃ̂Ōʂdouble
        Console.WriteLine("13.53 % 2.5 = {0}", 13.53 % 2.5); //double % double Ȃ̂Ōʂdouble
    }
}

oFAWKFp.84 mod01.cs

E̐܂ޏ]ZǉĎ

쐬

//AWKFp.84 mod01.cs
using System;
class mod01
{
    public static void Main()
    {
        Console.WriteLine("10 % 3 = {0}", 10 % 3); //int % int Ȃ̂Ōʂint
        Console.WriteLine("13.53 % 2 = {0}", 13.53 % 2); //double % int Ȃ̂Ōʂdouble
        Console.WriteLine("13.53 % 2.5 = {0}", 13.53 % 2.5); //double % double Ȃ̂Ōʂdouble
        Console.WriteLine("10 % -3 = {0}", 10 % -3); //10-3-3]1ƂȂ̂Œ
        Console.WriteLine("-10 % 3 = {0}", -10 % 3); //-103-3]-1ƂȂ̂Œ
        Console.WriteLine("-10 % -3 = {0}", -10 % -3); //-10-33]-1ƂȂ̂Œ
    }
}

\Fp.58uCNgZqAfNgZqv
